﻿@model SmartStore.PayPal.Models.PayPalExpressPaymentInfoModel
@{
    Layout = "";
}

@if (Model.CurrentPageIsBasket)
{
    <div id="paypal-checkout" class="my-2 ml-3">
        <a id="paypal-express-button" href="javascript:void(0)">
            <img alt="" src="@Url.Content(Model.SubmitButtonImageUrl)" />
        </a>
    </div>

	<script>
		$(function () {

			$('#paypal-express-button').on('click', function (e) {
				e.preventDefault();

				$.ajax({
					type: 'POST',
					url: '@Url.Action("SaveCartData", "ShoppingCart", new { area = "" })',
					data: $('#startcheckout').closest('form').serialize(),
					success: function (response) {
						if (response.success) {
							window.location = '@Url.Action("SubmitButton", "PayPalExpress", new { area = "SmartStore.PayPal" })';
						}
						else {
							displayNotification(response.message, 'error');
						}
					}
				});

				return false;
			});

		});
	</script>
}